<template>
	<view>
		<view v-if="listInfo.isShowHead" class="zk_new_list_head">
			<view class="zk_title_text">{{listInfo.headTitle}}</view>
			<view class="view-all-text" v-if="listInfo.isShowMore" @click=handleJumpAllList>
				查看全部
				<image class="notice-right-image" :src="getImgUrl('/applet_assets/safe_closed/right.png')" lazy-load="true" mode="scaleToFill" />
			</view>
		</view>
		<view class="content" v-if="newList.length > 0">
			<view class="my-card" v-for="(item, i) in newList" :key="i" @click="hanldeJumpDetail(item)">
				<view class="zk_new_list_left">
					<view class="zk_new_list_title text-ellipsis">{{item.title}}</view>
					<view class="zk_new_list_sub">
						<view class="zk_new_list_date">{{item.created_at}}</view>
						<tm-divider vertical :height="20" color="#8091A4"></tm-divider>
						<view class="zk_new_list_sub_title">{{item.projectName}}</view>
					</view>
				</view>
				<view class="zk_new_list_image">
					<!-- /设置默认图片的url -->
					<tm-image v-if="item.imgUrl" :width="196" :height="166" :src="item.imgUrl"></tm-image>
					<image v-else class="img" src="@/static/img/notic.png" mode="aspectFit" :lazy-load="true"></image>
				</view>
			</view>
		</view>
		
		<view class="graph-img" v-else>
			<image class="img" src="@/static/img/noData.png" mode="aspectFit"></image>
			<text class="tips">暂无数据~</text>
		</view>
		
	</view>
</template>

<script lang="ts" setup>
	import { ref, watch, reactive } from 'vue'
	import {ASSETS_HOST} from '@/config';
	import tmDivider from '@/tmui/components/tm-divider/tm-divider.vue'
	import tmImage from '@/tmui/components/tm-image/tm-image.vue';
	
	
	const props = defineProps({
	  listArr: Array,
	  isShowHead: Boolean,
	  isShowMore: Boolean,
	  title: String,
	  headTitle: String,
	})
	const newList = ref<any>([])
	const listInfo = reactive({
		headTitle: props.headTitle,
		isShowHead: props.isShowHead || true,
		title: props.title,
		isShowMore: props.isShowMore || false
	})
	watch(()=> props.listArr, (newVal, oldVal) => {
		newList.value = newVal
	}, {deep: true, immediate: true})
	
	const handleJumpAllList = ()=> {
		uni.navigateTo({
			url: '/subpkg/propertyNotice/index'
		})
	}
	const hanldeJumpDetail = (e:any) => {
		uni.navigateTo({
			url: `/subpkg/noticeDetail/index?id=${e.id}`
		})
	}
	const getImgUrl = (url:string) => {
		return ASSETS_HOST + url
	}
</script>

<style lang="scss" scoped>
	@import "~@/uni.scss";

.zk_new_list_head{
	display: flex;
	justify-content: space-between;
	padding-bottom: 16px;
	.zk_title_text{
		font-weight: $cus-font-weight;
		color: $uni-text-color;
		font-size: 32rpx;
	}
	
	.view-all-text {
		display: flex;
		align-items: center;
		font-size: 24rpx;
		color: $cus-color-1;
		
		.notice-right-image {
			width: 5px;
			height: 10px;
			margin-left: 10rpx;
		}
	}
	.zk_new_list_date{
		color: $cus-bg-color;
	}
	.zk_new_list_sub_title{
		margin-left: 12px;
		color: $cus-color-1;
	}
}
.content {
	.my-card {
		background: #FFFFFF;
		box-shadow: 0rpx 6rpx 8rpx 4rpx rgba(0,0,0,0.08);
		border-radius: 10rpx;
		padding: 20rpx;
		box-sizing: border-box;
		display: flex;
		justify-content: space-between;
		margin-bottom: 24rpx;
		
		
		.zk_new_list_left {
		  display: flex;
		  flex-direction: column;
		  justify-content: space-between;
		  
		  .zk_new_list_title {
			  width: 420rpx;
			  font-size: 28rpx;
			  color: #333333;
			  line-height: 40rpx;
		  }
		
		   .zk_new_list_sub {
			   display: flex;
			   align-items: center;
			   
			   .zk_new_list_date {
				   font-size: 24rpx;
				   color: #165DFF;
				   white-space: nowrap;
			   }
			   
			   .zk_new_list_sub_title {
				   font-size: 24rpx;
				   color: #8091A4;
				   width: 258rpx;
				   overflow: hidden;
				   display: block;
				   white-space: nowrap;
				   text-overflow: ellipsis;
			   }
		   }
		}
		
		.zk_new_list_image {
			.img {
				width: 196rpx;
				height: 166rpx;
			}
		}
	}
}

.graph-img {
	display: flex;
	align-items: center;
	justify-content: center;
	flex-direction: column;
	min-height: 360rpx;
	
	.img {
		width: 172rpx;
		height: 172rpx;
	}
	
	.tips {
		font-size: 28rpx;
		color: #BCBCBC;
		line-height: 24rpx;
		margin-top: 24rpx;
	}
}
</style>
